#!/usr/bin/env bash


# shellcheck disable=SC2164
cd spideradmin
# shellcheck disable=SC2009
spiderAdminPid=$( ps -ef | grep spideradmin | grep -v grep | awk '{print $2}')

if [ ! "$spiderAdminPid" ];then
  echo "[+]: spiderAdmin process is not exist"
  nohup spideradmin > spideradmin.log 2>&1 &
else
  kill -9 "$spiderAdminPid"
  nohup spideradmin > spideradmin.log 2>&1 &
fi
echo "[+]: spiderAdmin start successful ......"
# shellcheck disable=SC2009
scrapydPid=$( ps -ef | grep scrapyd | grep -v grep | awk '{print $2}')
# shellcheck disable=SC1073
# shellcheck disable=SC1046
if [ ! "$scrapydPid" ];then
  echo "[+]: scrapyd process is not exist ......"
  nohup scrapyd >scrapyd.log 2>&1 &
else
  kill -9 "$scrapydPid"
  nohup scrapyd>scrapyd.log 2>&1 &
fi

echo "[+]: spider start successful ......"



